package com.springcloud.market.stock.service.impl;

import com.springcloud.market.stock.mapper.StockMapper;
import com.springcloud.market.stock.pojo.Stock;
import com.springcloud.market.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StockServicelImpl implements StockService {
    @Autowired
    private StockMapper stockMapper;

    @Override
    public void reduce(Integer productId) {
        Stock stock = stockMapper.selectById(productId);
        stock.setCount(stock.getCount()-1);
        stockMapper.updateById(stock);
    }
}
